 <!DOCTYPE html>
<html>
<!--Made By kailuosoft.com, TEL 171 9992 9517 -->
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>凯络科技后台管理系统</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico"> <link href="__PUBLIC__/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="__PUBLIC__/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="__PUBLIC__/css/animate.min.css" rel="stylesheet">
    <link href="__PUBLIC__/css/style.min862f.css?v=4.1.0" rel="stylesheet">
	<link href="__PUBLIC__/css/page.css" rel="stylesheet">
    <link href="__PUBLIC__/css/new.css" rel="stylesheet">
	
	<script src="__PUBLIC__/js/jquery.min63b9.js?v=2.1.4"></script>
    <script src="__PUBLIC__/js/plugins/layer/layer.min.js"></script>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

   <script type="text/javascript">
		function page(n,s){
			var buyer=$('#buyer').val();
			location.href='purchase?pageNo='+n+'&pageSize='+s+'&buyer='+buyer;
	    	return false;
	    }
		
		function dele(id)
		{
		    layer.confirm('确定要删除吗？',
			              {btn:['确定','取消']},
							  function(){
							      location.href='order_delete?id='+id;
							  }
						  ),
						
						  function(){return false;} 
						  
		}
		
		/*function list_sort(name){
			if($('#asc').val()=='asc'){
				var asc='desc';
			}else{
				var asc='asc';
			}
			var title=$('#title').val();
			var phone=$('#phone').val();
			var orderno=$('#orderno').val();
			//location.href='find?pageNo='+{$count.pageNo}+'&pageSize='+{$count.pageSize}+'&title='+title+'&phone='+phone+'&orderno='+orderno+'&name='+name+'&asc='+asc;
		}*/
		
		/*$(document).ready(function(){
			$('.edit').dblclick(function(){
			name=$(this).attr('nameval');
				  nval=$(this).text();
				  id=$(this).parent().find('.id').val();
				 
				 $(this).parent().find('.id').attr('name','id');
			if(name=='status')
				 { 
					 if(nval == '货源充足'){
						 $(this).html("<select type='text' class='form-control' name='status'><option value='1' selected>货源充足</option><option value='2'>采购中</option><option value='3'>缺货</option><option value='4'>断货</option></select>");
					}else if(nval == '采购中'){
						 $(this).html("<select type='text' class='form-control' name='status'><option value='1' >货源充足</option><option value='2' selected>采购中</option><option value='3'>缺货</option><option value='4'>断货</option></select>");
					}else if(nval == '缺货'){
						 $(this).html("<select type='text' class='form-control' name='status'><option value='1'>货源充足</option><option value='2'>采购中</option><option value='3' selected>缺货</option><option value='4'>断货</option></select>");
					}else if(nval == '断货'){
						 $(this).html("<select type='text' class='form-control' name='status'><option value='1'>货源充足</option><option value='2'>采购中</option><option value='3'>缺货</option><option value='4' selected>断货</option></select>");
					}
					 
				 }else{
			$(this).html("<input type='text' name='"+name+"' value='"+nval+"' class='input-sm form-control' class='nameedit'>");
			$(this).children().focus().val(nval);}
			
			
				 
			$(this).children().blur(function(event){
				value=$(this).val();
					
					visitor_id=$('#visitor_id').val();
				
					$.ajax({
						url:"{:U('Address/address_edit')}", 
						data:'name='+name+'&value='+$(this).val()+'&id='+id+'&visitor_id='+visitor_id,
						type:"post",
						success:function(msg){
							 if(msg=='success')
							 {   
								 $(this).val(value);
							 }
							 else
							 {
								 $(this).val(nval);
							 }
						 }
					})
					
					if(name=='status')
					{
						if($(this).val()==1)
						{
							$(this).parent().html('货源充足');
						}
						else if($(this).val()==2)
						{
							$(this).parent().html('采购中');
						}
						else if($(this).val()==3)
						{
							$(this).parent().html('缺货');
						}
						else if($(this).val()==4)
						{
							$(this).parent().html('断货');
						}
						
					}
					else
					{
						 $(this).parent().html($(this).val());
					}
					$(this).remove();
		
				})
		    }) 
			
			
	   })*/
	</script>

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
         
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>缺货产品</h5>
                        
                    </div>
                    <div class="ibox-content">
                    <if condition ="$type eq '1'">
					    <form id="searchForm" class="form-inline" method="post" action="" >
					<div class="row">
                            <input type='hidden' name='pageNo' value='1' />
                            <input type='hidden' name='pageSize' value='10' />
                            <input type='hidden' id='name' name='name' value='{$order.name}' />
                            <input type='hidden' id='asc' name='asc' value='{$order.asc}' />
                            
                            <div class='search'>
                            
                                <select class="form-control" style="margin-top:-5px;" name="buyer">
                                    <option value="1">采购员A</option>
                                    <option value="2">采购员B</option>
                                    <option value="4">采购员C</option>
                                    <option value="5">采购员D</option>
                                    
                                </select>
                                
                                
							    <button type="submit" class="btn btn-sm btn-primary"> 搜索</button>
								<a class="btn btn-white btn-sm " href="javascript:window.location.reload(true);" data-toggle="tooltip" data-placement="left"   title="刷新"> <i class="glyphicon glyphicon-repeat"></i> 刷新</a>  
							    
                            </div>
                        </div>
					    </form>
                  </if>
						
                        <if condition="$type eq 2">
                                 <form name="aa" method="post" action="">
                                	<table class="table table-bordered table-striped table-hover"  style="width:100%;">
                                    <thead >
                                        <tr>
                                        	<th class="sort-column name" width="9%">采购员</th>
                                            <th class="sort-column name" width="10%">供应商</th>
                                            <th class="sort-column name" width="10%">SKU</th>
                                            <th class="sort-column name" width="6%">产品图片</th>
                                            <th class="sort-column name" width="10%">采购单价</th>
                                            <th class="sort-column name" width="10%">总数量</th>
                                            <th class="sort-column name" width="10%">业务员</th>
                                            <th class="sort-column name" width="10%">订单号</th>
                                            <th class="sort-column name" width="10%">产品数量</th>
                                            <th class="sort-column name" width="10%">历史订单</th>
                                             <th class="sort-column name" width="5%">备注</th>
                                        </tr>
                                    </thead>
                                    <tbody  id='tab' class="tab">
                                    	
                                        <foreach name="purchase_list" item="val" key="k">
                                        <tr>
                                            <td>{$val.buyer}</td>
                                            <td class="supplier">{$val.supplier}</td>
                                            <td class="sku" >{$val.sku}</td>
                                            <td class="main_pic" width="100px" height="100px" ><img src="{$val.main_pic}" width="100%" height="100%" alt="{$key}{$val.main_pic}" />
                                            </td>
                                            <td class="cost_price" >{$val.cost_price}</td>
                                            <td class="quantity">{$val['quantity']-$val['purchase_quantity']}</td>
                                        
                                            <td>{$val.salesman} </td>
                                            <td>{$val.order_number}<input type="hidden" class="btn btn-lg btn-primary" value="{$val.buyer}" name="buyer"></td>
                                            <td>{$val.quantity}</td>
                                           
                                            <td><if condition="$create_time[$k]['create_time'] neq $now_time">**该产品为历史订单</if></td>
                                            <td >{$val.remarks}</td>
                                       </tr>   
                                       </foreach>
                                       
                                    </tbody>
                                    <tfoot>
                                    	<tr>
                                        	<td colspan="11">
                                            	<input type="submit" class="btn btn-lg btn-primary" value="生成采购单" name="create"></input>
                                                &nbsp;
                                                <input type="button" class="btn btn-lg btn-primary" value="生成备货单"></input>
                                            </td>
                                        </tr>
                                    </tfoot>
                                </table>
                                </form>
                           		<else/>
                               
                          <foreach name="purchase_list" item="purchase" key="k">
                                 <form name="aa" method="post" action="">
                                	<table class="table table-bordered table-striped table-hover" style="width:100%;" class="tab">
                                    <thead >
                                        <tr>
                                        	<th class="sort-column name" width="9%">采购员</th>
                                            <th class="sort-column name" width="10%">供应商</th>
                                            <th class="sort-column name" width="10%">SKU</th>
                                            <th class="sort-column name" width="6%">产品图片</th>
                                            <th class="sort-column name" width="10%">采购单价</th>
                                            <th class="sort-column name" width="10%">总数量</th>
                                            <th class="sort-column name" width="10%">业务员</th>
                                            <th class="sort-column name" width="10%">订单号</th>
                                            <th class="sort-column name" width="10%">产品数量</th>
                                            <th class="sort-column name" width="10%">历史订单</th>
                                             <th class="sort-column name" width="5%">备注{$k}</th>
                                        </tr>
                                    </thead>
                                    <tbody  id='tab{$k}' class>
                                        <foreach name="purchase" item="val" key="key">
                                        
                                        <tr>
                                        	<input type="hidden" class="btn btn-lg btn-primary" value="{$val.buyer}" name="buyer"></input>
                                            <td class="buyer">
                                            	{$val.buyer}
                                            </td>
                                            <td class="supplier">{$val.supplier}</td>
                                            <td class="sku" >{$val.sku}</td>
                                            <td class="main_pic" width="100px" height="100px" class="main_pic" ><img src="{$val.main_pic}" width="100%" height="100%" alt="图片已丢失" />
                                            </td>
                                            <td class="cost_price" >{$val.cost_price}</td>
                                            <td class="quantity">{$val.quantity}</td>
                                        
                                            <td>{$val.salesman} </td>
                                            <td>{$val.order_number}</td>
                                            <td>{$val.quantity}</td>
                                           
                                            <td><if condition="$create_time[$k]['create_time'] neq $now_time">**该产品为历史订单</if></td>
                                            <td >{$val.remarks}</td>
                                       </tr>   
                                       </foreach>
                                       
                                    </tbody>
                                    <tfoot>
                                    	<tr>
                                        	<td colspan="11">
                                            	<input type="submit" class="btn btn-lg btn-primary" value="生成采购单" name="create"></input>
                                                &nbsp;
                                                <input type="button" class="btn btn-lg btn-primary" value="生成备货单"></input>
                                            </td>
                                        </tr>
                                    </tfoot>
                                </table>
                                </form>
                                </foreach>
                                 
                      </if>
                                
                                
                                
                               
                        
						<!--<table width="100%" border="0">
                          <tr>
                            <td >
                           <a class="btn btn-sm btn-primary" title="导入" id="recheck" >导出数据</a>&nbsp
                          </tr>
                        </table><br/>-->
                         
			         
						
	<!-- 分页代码 -->
<div class="fixed-table-pagination" style="display: block;">
	<div class="pull-left pagination-detail">
		<span class="pagination-info">显示第 1 到第 {$count.pageSize} 条记录，总共 {$count.count} 条记录</span>
		<span class="page-list">每页显示 
			<span class="btn-group dropup">
				<button type="button" class="btn btn-default  btn-outline dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
					<span class="page-size">{$count.pageSize}</span> <span class="caret"></span></button>
					<ul class="dropdown-menu" role="menu">
					<li class="<if condition=" $count.pageSize eq 10"> active </if>"><a href="javascript:page(1,10,'');">10</a></li>
					<li class="<if condition=" $count.pageSize eq 25"> active </if>"><a href="javascript:page(1,25,'');">25</a></li>
					<li class="<if condition=" $count.pageSize eq 50"> active </if>"><a href="javascript:page(1,50,'');">50</a></li>
					<li class="<if condition=" $count.pageSize eq 100"> active </if>"><a href="javascript:page(1,100,'');">100</a></li>
					</ul>
					</span> 条记录</span>
				</div>
				<div class="pull-right pagination-roll">
				<ul class="pagination pagination-outline">
					<li class="paginate_button <if condition=" $count.pageNo eq 1"> previous disabled </if>"><a href="javascript:" onClick="page(1,{$count.pageSize},'');"><i class="fa fa-angle-double-left"></i></a></li>
					<li class="paginate_button <if condition=" $count.pageNo eq 1"> previous disabled </if>"><a href="javascript:" onClick="page({$count.pageNo}-1,{$count.pageSize},'');"><i class="fa fa-angle-left"></i></a></li>
					 <if condition=" $count.countpage gt 10 "> 
					 	<if condition=" $count.pageNo lt 5 "> 
							<li class="paginate_button "><a href="javascript:" onClick="page(1,{$count.pageSize},'');" id="<?php echo ($count['pageNo']==1)?'current':'' ?>">1</a></li>
							<li class="paginate_button "><a href="javascript:" onClick="page(2,{$count.pageSize},'');" id="<?php echo ($count['pageNo']==2)?'current':'' ?>">2</a></li>
							<li class="paginate_button "><a href="javascript:" onClick="page(3,{$count.pageSize},'');" id="<?php echo ($count['pageNo']==3)?'current':'' ?>">3</a></li>
							<li class="paginate_button "><a href="javascript:" onClick="page(4,{$count.pageSize},'');" id="<?php echo ($count['pageNo']==4)?'current':'' ?>">4</a></li>
							<li class="paginate_button "><a href="javascript:" onClick="page(5,{$count.pageSize},'');" id="<?php echo ($count['pageNo']==5)?'current':'' ?>">5</a></li>
							<li class="paginate_button "><a href="javascript:" onClick="page(6,{$count.pageSize},'');" id="<?php echo ($count['pageNo']==6)?'current':'' ?>">6</a></li>
							<li class="paginate_button "><a href="javascript:" onClick="page(7,{$count.pageSize},'');" id="<?php echo ($count['pageNo']==7)?'current':'' ?>">7</a></li>
							<li class="paginate_button "><a href="javascript:" onClick="page(8,{$count.pageSize},'');" id="<?php echo ($count['pageNo']==8)?'current':'' ?>">8</a></li>
							<li class="paginate_button disabled"><a href="javascript:">...</a></li>
							<li class="paginate_button "><a href="javascript:" onClick="page({$count.countpage},{$count.pageSize},'');">{$count.countpage}</a></li>
						<elseif condition="$count.pageNo lt $count.num and $count.pageNo egt 5"/>
							<li class="paginate_button "><a href="javascript:" onClick="page(1,{$count.pageSize},'');">1</a></li>
							<li class="paginate_button disabled"><a href="javascript:">...</a></li>
							<li class="paginate_button "><a href="javascript:" onClick="page(<?php echo $count['pageNo']-3; ?>,{$count.pageSize},'');"><?php echo $count['pageNo']-3; ?></a></li>
							<li class="paginate_button "><a href="javascript:" onClick="page(<?php echo $count['pageNo']-2; ?>,{$count.pageSize},'');"><?php echo $count['pageNo']-2; ?></a></li>
							<li class="paginate_button "><a href="javascript:" onClick="page(<?php echo $count['pageNo']-1; ?>,{$count.pageSize},'');"><?php echo $count['pageNo']-1; ?></a></li>
							<li class="paginate_button "><a href="javascript:" onClick="page({$count.pageNo},{$count.pageSize},'');" id='current'><?php echo $count['pageNo']; ?></a></li>
							<li class="paginate_button "><a href="javascript:" onClick="page(<?php echo $count['pageNo']+1; ?>,{$count.pageSize},'');"><?php echo $count['pageNo']+1; ?></a></li>
							<li class="paginate_button "><a href="javascript:" onClick="page(<?php echo $count['pageNo']+2; ?>,{$count.pageSize},'');"><?php echo $count['pageNo']+2; ?></a></li> 
							<li class="paginate_button "><a href="javascript:" onClick="page(<?php echo $count['pageNo']+3; ?>,{$count.pageSize},'');"><?php echo $count['pageNo']+3; ?></a></li>
							<li class="paginate_button disabled"><a href="javascript:">...</a></li>
							<li class="paginate_button "><a href="javascript:" onClick="page({$count.countpage},{$count.pageSize},'');">{$count.countpage}</a></li>
						<else />
							<li class="paginate_button "><a href="javascript:" onClick="page(1,{$count.pageSize},'');">1</a></li>
							<li class="paginate_button disabled"><a href="javascript:">...</a></li>
							<li class="paginate_button "><a href="javascript:" onClick="page(<?php echo $count['countpage']-4; ?>,{$count.pageSize},'');" id="<?php echo ($count['pageNo']==($count['countpage']-4))?'current':'' ?>"><?php echo $count['countpage']-4; ?></a></li>
							<li class="paginate_button "><a href="javascript:" onClick="page(<?php echo $count['countpage']-3; ?>,{$count.pageSize},'');" id="<?php echo ($count['pageNo']==($count['countpage']-3))?'current':'' ?>"><?php echo $count['countpage']-3; ?></a></li>
							<li class="paginate_button "><a href="javascript:" onClick="page(<?php echo $count['countpage']-2; ?>,{$count.pageSize},'');" id="<?php echo ($count['pageNo']==($count['countpage']-2))?'current':'' ?>"><?php echo $count['countpage']-2; ?></a></li>
							<li class="paginate_button "><a href="javascript:" onClick="page(<?php echo $count['countpage']-1; ?>,{$count.pageSize},'');" id="<?php echo ($count['pageNo']==($count['countpage']-1))?'current':'' ?>"><?php echo $count['countpage']-1; ?></a></li>
							<li class="paginate_button "><a href="javascript:" onClick="page(<?php echo $count['countpage']; ?>,{$count.pageSize},'');" id="<?php echo ($count['pageNo']==$count['countpage'])?'current':'' ?>"><?php echo $count['countpage']; ?></a></li>
						</if>
					<else />
						<for start="0" end="$count.countpage" name='i'>
							<li class="paginate_button <if condition=" $count.pageNo eq $i+1"> previous disabled </if>"><a href="javascript:" onClick="page({$i+1},{$count.pageSize},'');" id="<?php echo ($count['pageNo']==($i+1))?'current':'' ?>">{$i+1}</a></li>
						</for>
					</if>
					<li class="paginate_button next <if condition=" $count.pageNo egt $count.countpage"> previous disabled </if>"><a href="javascript:" onClick="page({$count.pageNo}+1,{$count.pageSize},'');"><i class="fa fa-angle-right"></i></a></li>
					<li class="paginate_button next <if condition=" $count.pageNo egt $count.countpage"> previous disabled </if>"><a href="javascript:" onClick="page({$count.countpage},{$count.pageSize},'');"><i class="fa fa-angle-double-right"></i></a></li>
				</ul>
			</div>
		</div>
	<br/>
	<br/>
	</div>
	</div>
</div>

                    </div>
                </div>
            </div>
             
        </div>
         
    </div>
    <script src="__PUBLIC__/js/jquery.min63b9.js?v=2.1.4"></script>
    <script src="__PUBLIC__/js/bootstrap.min14ed.js?v=3.3.6"></script>
    <script src="__PUBLIC__/js/plugins/peity/jquery.peity.min.js"></script>
    <script src="__PUBLIC__/js/content.mine209.js?v=1.0.0"></script>
    <script src="__PUBLIC__/js/plugins/iCheck/icheck.min.js"></script>
    <script src="__PUBLIC__/js/demo/peity-demo.min.js"></script>
	<script src="__PUBLIC__/js/plugins/layer/laydate/laydate.js"></script>
    <script>
        $(document).ready(function(){$(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",})});
		 $(document).ready(function () {
		
            $('.check-all').iCheck({
			 
                checkboxClass: 'icheckbox_square-green',
                radioClass: 'iradio_square-green',
            });
        });
		
	/*
	$(document).ready(function() {
	$(function(){
		 function merge2() {     //可实现合并单元格,上下行来比较 
		 alert(222);
			var totalCols = $("#tab").find("tr:eq(0)").find("td").length; 
			var totalRows = $("#tab").find("tr").length; 
			for ( var i = totalCols-1; i >= 0; i--) { 
				if(i >= 3)continue;
				for ( var j = totalRows-1; j >= 0; j--) { 
					startCell = $("#tab").find("tr").eq(j).find("td").eq(i); 
					targetCell = $("#tab").find("tr").eq(j - 1).find("td").eq(i);	
				if (startCell.text() == targetCell.text() && targetCell.text() != "") { 
					
					if(i == 2){
						var two = 	$("#tab").find("tr").eq(j).find("td").eq(3); 
						var two_1 = $("#tab").find("tr").eq(j - 1).find("td").eq(3); 
						var there = $("#tab").find("tr").eq(j).find("td").eq(4); 
						var there_1 = $("#tab").find("tr").eq(j - 1).find("td").eq(4);
						var five = $("#tab").find("tr").eq(j).find("td").eq(5); 
						var sum = parseInt(five.html());
						var five_1 = $("#tab").find("tr").eq(j - 1).find("td").eq(5);
						two_1.attr("rowSpan", (two.attr("rowSpan")==undefined)?2:(eval(two.attr("rowSpan"))+1));
						there_1.attr("rowSpan", (there.attr("rowSpan")==undefined)?2:(eval(there.attr("rowSpan"))+1));
						five_1.attr("rowSpan", (five.attr("rowSpan")==undefined)?2:(eval(five.attr("rowSpan"))+1));
						five_1.html(sum+parseInt(five.html()));
						
						five.remove();
						two.remove();
						there.remove();
					}
					targetCell.attr("rowSpan", (startCell.attr("rowSpan")==undefined)?2:(eval(startCell.attr("rowSpan"))+1)); 
					startCell.remove(); 
				} 
			} 
			} 
		 } 
		 merge2();
	 })*/
	 
	 
$(document).ready(function() {
	$(function(){
		 function merge2() {     //可实现合并单元格,上下行来比较 
			var totalCols = $("#tab").find("tr:eq(0)").find("td").length;
			 
			var totalRows = $("#tab").find("tr").length; 
			if(totalRows > 1){
				for ( var i = totalCols-1; i >= 0; i--) { 
					if(i >= 3)continue;
					var sum =0;
					for ( var j = totalRows-1; j >= 0; j--) { 
						startCell = $("#tab").find("tr").eq(j).find("td").eq(i); 
						targetCell = $("#tab").find("tr").eq(j - 1).find("td").eq(i);	
					if (startCell.text() == targetCell.text() && targetCell.text() != "") { 
						
						if(i == 2){
							var two = 	$("#tab").find("tr").eq(j).find("td").eq(3); 
							var two_1 = $("#tab").find("tr").eq(j - 1).find("td").eq(3); 
							var there = $("#tab").find("tr").eq(j).find("td").eq(4); 
							var there_1 = $("#tab").find("tr").eq(j - 1).find("td").eq(4);
							
							var five = $("#tab").find("tr").eq(j).find("td").eq(5);
							var five_1 = $("#tab").find("tr").eq(j-1).find("td").eq(5); 
						/*	if(sum  == 0){
								sum = parseInt(five_1.html()) + parseInt(five.html());
							}else{
								sum += 	parseInt(five_1.html());
							}
							console.log(five_1.html());*/
							//var sum = parseInt(five.html());
							//var five_1 = $("#tab").find("tr").eq(j - 1).find("td").eq(5);
							two_1.attr("rowSpan", (two.attr("rowSpan")==undefined)?2:(eval(two.attr("rowSpan"))+1));
							there_1.attr("rowSpan", (there.attr("rowSpan")==undefined)?2:(eval(there.attr("rowSpan"))+1));
							five_1.attr("rowSpan", (five.attr("rowSpan")==undefined)?2:(eval(five.attr("rowSpan"))+1));
							
							
							five.remove();
							two.remove();
							there.remove();
						}
						targetCell.attr("rowSpan", (startCell.attr("rowSpan")==undefined)?2:(eval(startCell.attr("rowSpan"))+1)); 
						startCell.remove(); 
					} 
				} 
				} 
			 } 
		 }
		 merge2();
		
	 })
	 
	 
	 
	 
	  $(function(){
		 function merge3() {     //可实现合并单元格,上下行来比较 
		 var sum = "{$k}";
		 
		 for(var k=0;k<=sum;k++){
			var totalCols = $("#tab"+k).find("tr:eq(0)").find("td").length;
			var totalRows = $("#tab"+k).find("tr").length;
			if(totalRows > 1){
				
				for ( var i = totalCols-1; i >= 0; i--) { 
					if(i >= 3)continue;
					var sum =0;
					for ( var j = totalRows-1; j >= 0; j--) { 
						startCell = $("#tab"+k).find("tr").eq(j).find("td").eq(i); 
						targetCell = $("#tab"+k).find("tr").eq(j - 1).find("td").eq(i);	
					if (startCell.text() == targetCell.text() && targetCell.text() != "") { 
						
						if(i == 2){
							var two = 	$("#tab"+k).find("tr").eq(j).find("td").eq(3); 
							var two_1 = $("#tab"+k).find("tr").eq(j - 1).find("td").eq(3); 
							var there = $("#tab"+k).find("tr").eq(j).find("td").eq(4); 
							var there_1 = $("#tab"+k).find("tr").eq(j - 1).find("td").eq(4);
							
							var five = $("#tab"+k).find("tr").eq(j).find("td").eq(5);
							var five_1 = $("#tab"+k).find("tr").eq(j-1).find("td").eq(5); 
						/*	if(sum  == 0){
								sum = parseInt(five_1.html()) + parseInt(five.html());
							}else{
								sum += 	parseInt(five_1.html());
							}
							console.log(five_1.html());*/
							//var sum = parseInt(five.html());
							//var five_1 = $("#tab").find("tr").eq(j - 1).find("td").eq(5);
							two_1.attr("rowSpan", (two.attr("rowSpan")==undefined)?2:(eval(two.attr("rowSpan"))+1));
							there_1.attr("rowSpan", (there.attr("rowSpan")==undefined)?2:(eval(there.attr("rowSpan"))+1));
							five_1.attr("rowSpan", (five.attr("rowSpan")==undefined)?2:(eval(five.attr("rowSpan"))+1));
							
							
							five.remove();
							two.remove();
							there.remove();
						}
						targetCell.attr("rowSpan", (startCell.attr("rowSpan")==undefined)?2:(eval(startCell.attr("rowSpan"))+1)); 
						startCell.remove(); 
					} 
				} 
				} 
			 } 
		 }
		}
		 merge3();
	  })

	/*var sum = "{$sum}";
	for(var i = 0;i<sum;i++){
	var str = '';
	var one = 1;
	var now = -1;
	$(".tb_"+i+" .buyer").each(function(e){
		if($(this).html() == str){
			if(now == -1){
				now = e;
			}
			one++;
			str = $(this).html();
		}else{
			str = $(this).html();
		}
			
	});
	if(one > 1){
		$(".tb_"+i+" .buyer").eq(now-1).attr("rowspan",one);
		$(".tb_"+i+" .buyer").each(function(e){
			if(e > now-1){
				$(this).remove(); 
			}
		})
		one = 1;
		now =  -1;
	}
	
	
	
	$(".tb_"+i+" .supplier").each(function(e){
		if($(this).html() == str){
			if(now == -1){
				now = e;
			}
			one++;
			str = $(this).html();
		}else{
			str = $(this).html();
		}
			
	});
	if(one > 1){
		$(".tb_"+i+" .supplier").eq(now-1).attr("rowspan",one);
		$(".tb_"+i+" .supplier").each(function(e){
			if(e > now-1){
				$(this).remove();
			}
		})
		one = 1;
		now =  -1;
	}
	
	
	$(".tb_"+i+" .sku").each(function(e){
		if($(this).html() == str){
			if(now == -1){
				now = e;
			}
			one++;
			str = $(this).html();
		}else{
			str = $(this).html();
		}
			
	});
	if(one > 1){
		$(".tb_"+i+" .sku").eq(now-1).attr("rowspan",one);
		$(".tb_"+i+" .cost_price").eq(now-1).attr("rowspan",one);
		$(".tb_"+i+" .quantity").eq(now-1).attr("rowspan",one);
		var p_sum = 0;
		var total = 0;
		
		$(".tb_"+i+" .sku").each(function(e){
			if(e >= now -1){
				p_sum = parseFloat($(".tb_"+i+" .cost_price").eq(e).html());
				total += parseInt($(".tb_"+i+" .quantity").eq(e).html());
			}
			if(e > now-1){
				$(this).remove();
				$(".tb_"+i+" .cost_price").eq(e).remove();
				$(".tb_"+i+" .quantity").eq(e).remove();
				
			}
		})
		$(".tb_"+i+" .cost_price").eq(now-1).html(p_sum);
		$(".tb_"+i+" .quantity").eq(now-1).html(total);
		one = 1;
		now =  -1;
	}
	
	$(".tb_"+i+" .main_pic").each(function(e){
		if($(this).html() == str){
			if(now == -1){
				now = e;
			}
			one++;
			str = $(this).html();
		}else{
			str = $(this).html();
		}
			
	});
	if(one > 1){
		$(".tb_"+i+" .main_pic").eq(now-1).attr("rowspan",one);
		$(".tb_"+i+" .main_pic").each(function(e){ 
			
			
			$(".tb_"+i+" .sku").each(function(e){
				if($(this).html() == str){
					if(now == -1){
						now = e;
					}
					one++;
					str = $(this).html();
				}else{
					str = $(this).html();
				}
					
			});
			
			
			
			if(e > now-1){
				$(this).remove();
			}
		})
		one = 1;
		now =  -1;
	}*/
	/*
	$(".tb_"+i+" .cost_price").each(function(e){
		if($(this).html() == str){
			if(now == -1){
				now = e;
			}
			one++;
			str = $(this).html();
		}else{
			str = $(this).html();
		}
			
	});
	if(one > 1){
		$(".tb_"+i+" .cost_price").eq(now-1).attr("rowspan",one);
		$(".tb_"+i+" .cost_price").each(function(e){
			console.log(e);
			console.log(now);
			if(e > now-1){
				$(this).remove();
			}
		})
		one = 1;
		now =  -1;
	}
	/*str = '';
	
	
	
	$(".supplier").each(function(e){
		if($(this).html() == str){	
			if(now == 0){
				now = e;
			}
			one++;
			str = $(this).html();
			$(this).remove();
		}else{
			str = $(this).html();
		}
			
	});
	if(one > 1){
		$(".supplier").eq(now).attr("rowspan",one);
		one = 1;
		now = 0;
	}
	str = '';
	
	
	
	$(".sku").each(function(e){
		if($(this).html() == str){	
		
			if(now == 0){
				now = e;
			}
			one++;
			str = $(this).html();
			$(this).remove();
		}else{
			str = $(this).html();
		}
			
	});
	if(one > 1){
		var where = $('.sku').index();
		$(".sku").eq(now).attr("rowspan",one);
		one = 1;
		now = 0;
	}
	str = '';
	
	
	
	
	$(".main_pic").each(function(e){
		if($(this).html() == str){
			if(now == 0){
				now = e;
			}	
			one++;
			str = $(this).html();
			$(this).remove();
		}else{
			str = $(this).html();
		}
			
	});
	if(one > 1){
		var where = $('.main_pic').index();
		$(".main_pic").eq(now).attr("rowspan",one);
		one = 1;
		now = 0;
	}
	str = '';
	
	
	
	
	$(".cost_price").each(function(e){
		if($(this).html() == str){
			if(now == 0){
				now = e;
			}		
			one++;
			str = $(this).html();
			$(this).remove();
		}else{
			str = $(this).html();
		}
			
	});
	if(one > 1){
		$(".cost_price").eq(now).attr("rowspan",one);
		one = 1;
		now = 0;
	}
	str = '';
	
	
	
	$(".total").each(function(e){
		var couaaant = $('.sku').getAttribute('rowspan');
		if($('.sku').html() == str){	
			one++;
			str = $(this).html();
			$(this).remove();
		}else{
			str = $(this).html();
		}
			
	});
	if(one > 1){
		$(".cost_price").eq(0).attr("rowspan",one);
		one = 1;
	}
	str = '';
	
	
    $('.check-all').on('ifChecked', function(event){ //ifCreated 事件应该在插件初始化之前绑定 
    	  $('.i-checks').iCheck('check');
    	});

    $('.check-all').on('ifUnchecked', function(event){ //ifCreated 事件应该在插件初始化之前绑定 
    	  $('.i-checks').iCheck('uncheck');
    	});
		
     
	  $('#check').click(function(){
		    tids='';
		    $('.i-checks').each(function(){
				if($(this).prop('checked'))
				{
					tids+=$(this).val()+',';
				}
			 })
		    $(this).attr('href','shenhe?tids='+tids);
			
		  }) 
		  
	 $('#recheck').click(function(){
		    tids='';
		    $('.i-checks').each(function(){
				if($(this).prop('checked'))
				{
					tids+=$(this).val()+',';
				}
			 })
			 if(tids=='')
			 {
				 layer.alert('请选择订单');
				 return false
			 }
		    $(this).attr('href','gocheck?tids='+tids);
			
	  }) 
	  */
	//}
    
});
    </script>
    <div style="display:none"><script language="javascript" type="text/javascript" src="http://js.users.51.la/17825721.js"></script>
<noscript><a href="http://www.51.la/?17825721" target="_blank"><img alt="&#x6211;&#x8981;&#x5566;&#x514D;&#x8D39;&#x7EDF;&#x8BA1;" src="http://img.users.51.la/17825721.asp" style="border:none" /></a></noscript></div>
</body>
<!--Made By kailuosoft.com, TEL 171 9992 9517 -->
<script  type="text/javascript"  src="http://g.tbcdn.cn/sj/securesdk/0.0.3/securesdk_v2.js"  id="J_secure_sdk_v2" data-appkey="23416550"></script>
</html>
